package com.example.bootdemo.listeners;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationStartingEvent;

import org.springframework.context.ApplicationListener;

public class MyAppStartingListener implements ApplicationListener<ApplicationStartingEvent> {

    private static Logger logger = LoggerFactory.getLogger(MyAppStartingListener.class);
    @Override
    public void onApplicationEvent(ApplicationStartingEvent applicationStartingEvent) {

        logger.info("监听到ApplicationStartingEvent事件......");

        String[] args = applicationStartingEvent.getArgs();
        if(args.length>0){
            for(int i=0;i<args.length;i++){
                logger.info("args["+i+"]="+args[i]);
            }
        }
        String className = applicationStartingEvent.getSource().getClass().getName();
        logger.info("className={}",className);

    }
}
